/*
 * Copyright 2011 Kim Lindhardt Madsen
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package dk.lindhardt.gwt.geie.client;

import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.Widget;
import dk.lindhardt.gwt.geie.shared.Link;

/**
 * User: AnAmuser
 * Date: 10-07-11
 * <p/>
 * Wraps a widget in an anchor. Holds the widget as a child
 */
public class GeieAnchor extends Anchor {

   private Widget child;
   private Link link;

   /**
    * Wraps the child in an anchor
    * @param child the wrapped widget
    * @param link the link
    */
   public GeieAnchor(Widget child, Link link) {
      super();

      this.child = child;
      this.link = link;

      getElement().appendChild(child.getElement());
      setHref(link.getDestination());
      setTarget("_blank");
   }

   /**
    * Gets the child element in this anchor
    * @return the child element
    */
   public Widget getChild() {
      return child;
   }

   /**
    * Gets the link used in this anchor
    * @return the link
    */
   public Link getLink() {
      return link;
   }
}
